I want to iterate through all modules in a folder whether open or not. |
Re: all modules in folder for item in folder |
Re: all modules in folder You need to use the item in folder loop. This includes all items in the current folder, including deleted items. It does not recurse into subfolders so you need to program that yourself if required. The following should get you started.
void processModule(string mName)
{
Module m = null
m = read(mName, false)
if (null m)
{
print("ERROR opening module " mName "\n")
return
}
print(mName " ok\n")
close(m)
}
void processFolder(Folder f)
{
Item i
for i in f do
{
if (isDeleted(i)) continue
if (type(i) == "Folder")
{
processFolder(folder(fullName(i)))
}
else if (type(i) == "Formal")
{
processModule(fullName(i))
}
}
}
processFolder(current Folder)
|
Re: all modules in folder Tony_Goodman - Wed Jun 17 09:39:29 EDT 2009 You need to use the item in folder loop. This includes all items in the current folder, including deleted items. It does not recurse into subfolders so you need to program that yourself if required. The following should get you started.
void processModule(string mName)
{
Module m = null
m = read(mName, false)
if (null m)
{
print("ERROR opening module " mName "\n")
return
}
print(mName " ok\n")
close(m)
}
void processFolder(Folder f)
{
Item i
for i in f do
{
if (isDeleted(i)) continue
if (type(i) == "Folder")
{
processFolder(folder(fullName(i)))
}
else if (type(i) == "Formal")
{
processModule(fullName(i))
}
}
}
processFolder(current Folder)
|
Re: all modules in folder llandale - Wed Jun 17 11:59:30 EDT 2009
1. count all of the relevant modules = no_modules 2. create string modulesno_modules 3. iterate again and write the full name of the modules into the array 4. run sort modulesno_modules 5. iterate again over the array If you have a nice structure with folders containing only folders or modules this makes for a nice sorting... Kristian |
Re: all modules in folder SystemAdmin - Wed Jul 01 07:11:52 EDT 2009 Skip foobar = createString the items in the skip list are automatically sorted alphabetically |
Re: all modules in folder SystemAdmin - Wed Jul 01 07:43:45 EDT 2009 Yes, sorted in KEY order. Try the following:
Item itm
string NameBase
Skip skpAlpha = createString() // KEY 'string' base name; DATA: 'string' base Name
Skip skpFound = create() // KEY 'int' order, DATAL 'string' base Name
int Order = 0
for itm in (current Folder) do
{ put(skpAlpha, name(itm), name(itm))
put(skpFound, Order++, name(itm))
}
print "** Alpha Order:\n"
for NameBase in skpAlpha do
{ print "\t" NameBase "\n"
}
print "** Found Order:\n"
for NameBase in skpFound do
{ print "\t" NameBase "\n"
}
delete(skpAlpha)
delete(skpFound)
|